﻿'usbioctl.bi
' Copyright (c) 2024 CM.Wang
' Freeware. Use at your own risk.

#pragma once

#include once "win/winnt.bi"

Extern "C"
	
	#define __USBIOCTL_H__
	#define FAR
	#define __USB200_H__
	#define __USBSPEC_H__
	
	Type _USB_DEVICE_SPEED As Long
	Enum
		UsbLowSpeed = 0
		UsbFullSpeed
		UsbHighSpeed
		UsbSuperSpeed
	End Enum
	
	Type USB_DEVICE_SPEED As _USB_DEVICE_SPEED
	
	Type _USB_DEVICE_TYPE As Long
	Enum
		Usb11Device = 0
		Usb20Device
	End Enum
	
	Type USB_DEVICE_TYPE As _USB_DEVICE_TYPE
	
	Union _BM_REQUEST_TYPE
		'' TODO: __C89_NAMELESS struct _BM { UCHAR Recipient:2; UCHAR Reserved:3; UCHAR Type:2; UCHAR Dir:1; };
		B As UCHAR
	End Union
	
	Type BM_REQUEST_TYPE As _BM_REQUEST_TYPE
	Type PBM_REQUEST_TYPE As _BM_REQUEST_TYPE Ptr
	
	Union _wValue
		'' TODO: __C89_NAMELESS struct { UCHAR LowByte; UCHAR HiByte; };
		W As UShort
	End Union
	
	Union _wIndex
		'' TODO: __C89_NAMELESS struct { UCHAR LowByte; UCHAR HiByte; };
		W As UShort
	End Union
	
	Type _USB_DEFAULT_PIPE_SETUP_PACKET
		bmRequestType As BM_REQUEST_TYPE
		bRequest As UCHAR
		wValue As _wValue
		wIndex As _wIndex
		wLength As UShort
	End Type
	
	Type USB_DEFAULT_PIPE_SETUP_PACKET As _USB_DEFAULT_PIPE_SETUP_PACKET
	Type PUSB_DEFAULT_PIPE_SETUP_PACKET As _USB_DEFAULT_PIPE_SETUP_PACKET Ptr
	Const BMREQUEST_HOST_TO_DEVICE = 0
	Const BMREQUEST_DEVICE_TO_HOST = 1
	Const BMREQUEST_STANDARD = 0
	Const BMREQUEST_CLASS = 1
	Const BMREQUEST_VENDOR = 2
	Const BMREQUEST_TO_DEVICE = 0
	Const BMREQUEST_TO_INTERFACE = 1
	Const BMREQUEST_TO_ENDPOINT = 2
	Const BMREQUEST_TO_OTHER = 3
	'' TODO: #define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((USHORT) (((USHORT) d) << 8 | i))
	Const USB_REQUEST_GET_STATUS = &h00
	Const USB_REQUEST_CLEAR_FEATURE = &h01
	Const USB_REQUEST_SET_FEATURE = &h03
	Const USB_REQUEST_SET_ADDRESS = &h05
	Const USB_REQUEST_GET_DESCRIPTOR = &h06
	Const USB_REQUEST_SET_DESCRIPTOR = &h07
	Const USB_REQUEST_GET_CONFIGURATION = &h08
	Const USB_REQUEST_SET_CONFIGURATION = &h09
	Const USB_REQUEST_GET_INTERFACE = &h0a
	Const USB_REQUEST_SET_INTERFACE = &h0b
	Const USB_REQUEST_SYNC_FRAME = &h0c
	Const USB_REQUEST_SET_SEL = &h30
	Const USB_REQUEST_ISOCH_DELAY = &h31
	Const USB_DEVICE_DESCRIPTOR_TYPE = &h01
	Const USB_CONFIGURATION_DESCRIPTOR_TYPE = &h02
	Const USB_STRING_DESCRIPTOR_TYPE = &h03
	Const USB_INTERFACE_DESCRIPTOR_TYPE = &h04
	Const USB_ENDPOINT_DESCRIPTOR_TYPE = &h05
	Const USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE = &h06
	Const USB_OTHER_SPEED_CONFIGURATION_DESCRIPTOR_TYPE = &h07
	Const USB_INTERFACE_POWER_DESCRIPTOR_TYPE = &h08
	Const USB_OTG_DESCRIPTOR_TYPE = &h09
	Const USB_DEBUG_DESCRIPTOR_TYPE = &h0a
	Const USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE = &h0b
	Const USB_BOS_DESCRIPTOR_TYPE = &h0f
	Const USB_DEVICE_CAPABILITY_DESCRIPTOR_TYPE = &h10
	Const USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_TYPE = &h30
	Const USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR_TYPE = &h31
	Const USB_RESERVED_DESCRIPTOR_TYPE = &h06
	Const USB_CONFIG_POWER_DESCRIPTOR_TYPE = &h07
	Const USB_FEATURE_ENDPOINT_STALL = &h00
	Const USB_FEATURE_REMOTE_WAKEUP = &h01
	Const USB_FEATURE_TEST_MODE = &h02
	Const USB_FEATURE_FUNCTION_SUSPEND = &h00
	Const USB_FEATURE_U1_ENABLE = &h30
	Const USB_FEATURE_U2_ENABLE = &h31
	Const USB_FEATURE_LTM_ENABLE = &h32
	Const USB_FEATURE_LDM_ENABLE = &h35
	Const USB_FEATURE_BATTERY_WAKE_MASK = &h28
	Const USB_FEATURE_OS_IS_PD_AWARE = &h29
	Const USB_FEATURE_POLICY_MODE = &h2A
	Const USB_FEATURE_CHARGING_POLICY = &h36
	Const USB_CHARGING_POLICY_DEFAULT = &h00
	Const USB_CHARGING_POLICY_ICCHPF = &h01
	Const USB_CHARGING_POLICY_ICCLPF = &h02
	Const USB_CHARGING_POLICY_NO_POWER = &h03
	Const USB_STATUS_PORT_STATUS = &h00
	Const USB_STATUS_PD_STATUS = &h01
	Const USB_STATUS_EXT_PORT_STATUS = &h02
	Const USB_GETSTATUS_SELF_POWERED = &h01
	Const USB_GETSTATUS_REMOTE_WAKEUP_ENABLED = &h02
	Const USB_GETSTATUS_U1_ENABLE = &h04
	Const USB_GETSTATUS_U2_ENABLE = &h08
	Const USB_GETSTATUS_LTM_ENABLE = &h10
	
	Union _USB_DEVICE_STATUS
		AsUshort16 As UShort
		'' TODO: __C89_NAMELESS struct { USHORT SelfPowered : 1; USHORT RemoteWakeup : 1; USHORT U1Enable : 1; USHORT U2Enable : 1; USHORT LtmEnable : 1; USHORT Reserved : 11; };
	End Union
	
	Type USB_DEVICE_STATUS As _USB_DEVICE_STATUS
	Type PUSB_DEVICE_STATUS As _USB_DEVICE_STATUS Ptr
	
	Union _USB_INTERFACE_STATUS
		AsUshort16 As UShort
		'' TODO: __C89_NAMELESS struct { USHORT RemoteWakeupCapable : 1; USHORT RemoteWakeupEnabled : 1; USHORT Reserved : 14; };
	End Union
	
	Type USB_INTERFACE_STATUS As _USB_INTERFACE_STATUS
	Type PUSB_INTERFACE_STATUS As _USB_INTERFACE_STATUS Ptr
	
	Union _USB_ENDPOINT_STATUS
		AsUshort16 As UShort
		'' TODO: __C89_NAMELESS struct { USHORT Halt : 1; USHORT Reserved : 15; };
	End Union
	
	Type USB_ENDPOINT_STATUS As _USB_ENDPOINT_STATUS
	Type PUSB_ENDPOINT_STATUS As _USB_ENDPOINT_STATUS Ptr
	
	Type _USB_COMMON_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
	End Type
	
	Type USB_COMMON_DESCRIPTOR As _USB_COMMON_DESCRIPTOR
	Type PUSB_COMMON_DESCRIPTOR As _USB_COMMON_DESCRIPTOR Ptr
	
	Type _USB_DEVICE_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bcdUSB As UShort
		bDeviceClass As UCHAR
		bDeviceSubClass As UCHAR
		bDeviceProtocol As UCHAR
		bMaxPacketSize0 As UCHAR
		idVendor As UShort
		idProduct As UShort
		bcdDevice As UShort
		iManufacturer As UCHAR
		iProduct As UCHAR
		iSerialNumber As UCHAR
		bNumConfigurations As UCHAR
	End Type
	
	Type USB_DEVICE_DESCRIPTOR As _USB_DEVICE_DESCRIPTOR
	Type PUSB_DEVICE_DESCRIPTOR As _USB_DEVICE_DESCRIPTOR Ptr
	Const USB_DEVICE_CLASS_RESERVED = &h00
	Const USB_DEVICE_CLASS_AUDIO = &h01
	Const USB_DEVICE_CLASS_COMMUNICATIONS = &h02
	Const USB_DEVICE_CLASS_HUMAN_INTERFACE = &h03
	Const USB_DEVICE_CLASS_MONITOR = &h04
	Const USB_DEVICE_CLASS_PHYSICAL_INTERFACE = &h05
	Const USB_DEVICE_CLASS_POWER = &h06
	Const USB_DEVICE_CLASS_IMAGE = &h06
	const USB_DEVICE_CLASS_PRINTER = &h07
	const USB_DEVICE_CLASS_STORAGE = &h08
	const USB_DEVICE_CLASS_HUB = &h09
	const USB_DEVICE_CLASS_CDC_DATA = &h0a
	const USB_DEVICE_CLASS_SMART_CARD = &h0b
	Const USB_DEVICE_CLASS_CONTENT_SECURITY = &h0d
	Const USB_DEVICE_CLASS_VIDEO = &h0e
	Const USB_DEVICE_CLASS_PERSONAL_HEALTHCARE = &h0f
	Const USB_DEVICE_CLASS_AUDIO_VIDEO = &h10
	Const USB_DEVICE_CLASS_BILLBOARD = &h11
	Const USB_DEVICE_CLASS_DIAGNOSTIC_DEVICE = &HDC
	Const USB_DEVICE_CLASS_WIRELESS_CONTROLLER = &he0
	Const USB_DEVICE_CLASS_MISCELLANEOUS = &hef
	Const USB_DEVICE_CLASS_APPLICATION_SPECIFIC = &hfe
	Const USB_DEVICE_CLASS_VENDOR_SPECIFIC = &hff
	
	Type _USB_DEVICE_QUALIFIER_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bcdUSB As UShort
		bDeviceClass As UCHAR
		bDeviceSubClass As UCHAR
		bDeviceProtocol As UCHAR
		bMaxPacketSize0 As UCHAR
		bNumConfigurations As UCHAR
		bReserved As UCHAR
	End Type
	
	Type USB_DEVICE_QUALIFIER_DESCRIPTOR As _USB_DEVICE_QUALIFIER_DESCRIPTOR
	Type PUSB_DEVICE_QUALIFIER_DESCRIPTOR As _USB_DEVICE_QUALIFIER_DESCRIPTOR Ptr
	
	Type _USB_BOS_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		wTotalLength As UShort
		bNumDeviceCaps As UCHAR
	End Type
	
	Type USB_BOS_DESCRIPTOR As _USB_BOS_DESCRIPTOR
	Type PUSB_BOS_DESCRIPTOR As _USB_BOS_DESCRIPTOR Ptr
	Const USB_DEVICE_CAPABILITY_WIRELESS_USB = &h01
	Const USB_DEVICE_CAPABILITY_USB20_EXTENSION = &h02
	Const USB_DEVICE_CAPABILITY_SUPERSPEED_USB = &h03
	Const USB_DEVICE_CAPABILITY_CONTAINER_ID = &h04
	Const USB_DEVICE_CAPABILITY_PLATFORM = &h05
	Const USB_DEVICE_CAPABILITY_POWER_DELIVERY = &h06
	Const USB_DEVICE_CAPABILITY_BATTERY_INFO = &h07
	Const USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT = &h08
	Const USB_DEVICE_CAPABILITY_PD_PROVIDER_PORT = &h09
	Const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB = &h0A
	Const USB_DEVICE_CAPABILITY_PRECISION_TIME_MEASUREMENT = &h0B
	Const USB_DEVICE_CAPABILITY_BILLBOARD = &h0D
	
	Union _USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR_bmAttributes
		AsUlong As ULong
		'' TODO: __C89_NAMELESS struct { ULONG Reserved:1; ULONG LPMCapable:1; ULONG BESLAndAlternateHIRDSupported:1; ULONG BaselineBESLValid:1; ULONG DeepBESLValid:1; ULONG Reserved1:3; ULONG BaselineBESL:4; ULONG DeepBESL:4; ULONG Reserved2:16; };
	End Union
	
	Type _USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bDevCapabilityType As UCHAR
		bmAttributes As _USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR_bmAttributes
	End Type
	
	Type USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR As _USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR
	Type PUSB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR As _USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR Ptr
	Const USB_DEVICE_CAPABILITY_USB20_EXTENSION_BMATTRIBUTES_RESERVED_MASK = &hffff00e1
	
	Union _USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR_bmAttributes
		AsUlong As ULong
		'' TODO: __C89_NAMELESS struct { ULONG Reserved1:1; ULONG BatteryCharging:1; ULONG USBPowerDelivery:1; ULONG Provider:1; ULONG Consumer:1; ULONG ChargingPolicy:1; ULONG TypeCCurrent:1; ULONG Reserved2:1; ULONG ACSupply:1; ULONG Battery:1; ULONG Other:1; ULONG NumBatteries:3; ULONG UsesVbus:1; ULONG Reserved3:17; };
	End Union
	
	Type _USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bDevCapabilityType As UCHAR
		bReserved As UCHAR
		bmAttributes As _USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR_bmAttributes
		bmProviderPorts As UShort
		bmConsumerPorts As UShort
		bcdBCVersion As UShort
		bcdPDVersion As UShort
		bcdUSBTypeCVersion As UShort
	End Type
	
	Type USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR As _USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR
	Type PUSB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR As _USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR Ptr
	
	Union _USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR_bmCapabilities
		AsUshort As UShort
		'' TODO: __C89_NAMELESS struct { USHORT BatteryCharging:1; USHORT USBPowerDelivery:1; USHORT USBTypeCCurrent:1; USHORT Reserved:13; };
	End Union
	
	Type _USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bDevCapabilityType As UCHAR
		bReserved As UCHAR
		bmCapabilities As _USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR_bmCapabilities
		wMinVoltage As UShort
		wMaxVoltage As UShort
		wReserved As UShort
		dwMaxOperatingPower As ULong
		dwMaxPeakPower As ULong
		dwMaxPeakPowerTime As ULong
	End Type
	
	Type USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR As _USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR
	Type PUSB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR As _USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR Ptr
	
	Type _USB_DEVICE_CAPABILITY_SUPERSPEED_USB_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bDevCapabilityType As UCHAR
		bmAttributes As UCHAR
		wSpeedsSupported As UShort
		bFunctionalitySupport As UCHAR
		bU1DevExitLat As UCHAR
		wU2DevExitLat As UShort
	End Type
	
	Type USB_DEVICE_CAPABILITY_SUPERSPEED_USB_DESCRIPTOR As _USB_DEVICE_CAPABILITY_SUPERSPEED_USB_DESCRIPTOR
	Type PUSB_DEVICE_CAPABILITY_SUPERSPEED_USB_DESCRIPTOR As _USB_DEVICE_CAPABILITY_SUPERSPEED_USB_DESCRIPTOR Ptr
	Const USB_DEVICE_CAPABILITY_SUPERSPEED_BMATTRIBUTES_RESERVED_MASK = &hfd
	Const USB_DEVICE_CAPABILITY_SUPERSPEED_BMATTRIBUTES_LTM_CAPABLE = &h02
	Const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_RESERVED_MASK = &hfff0
	Const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_LOW = &h0001
	Const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_FULL = &h0002
	Const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_HIGH = &h0004
	Const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_SUPER = &h0008
	Const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_LOW = &h0001
	Const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_FULL = &h0002
	Const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_HIGH = &h0004
	Const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_SUPER = &h0008
	Const USB_DEVICE_CAPABILITY_SUPERSPEED_U1_DEVICE_EXIT_MAX_VALUE = &h0a
	Const USB_DEVICE_CAPABILITY_SUPERSPEED_U2_DEVICE_EXIT_MAX_VALUE = &h07ff
	Const USB_DEVICE_CAPABILITY_MAX_U1_LATENCY = &h0a
	Const USB_DEVICE_CAPABILITY_MAX_U2_LATENCY = &h07ff
	Const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_LSE_BPS = 0
	Const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_LSE_KBPS = 1
	Const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_LSE_MBPS = 2
	Const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_LSE_GBPS = 3
	Const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_MODE_SYMMETRIC = 0
	Const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_MODE_ASYMMETRIC = 1
	Const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_DIR_RX = 0
	Const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_DIR_TX = 1
	Const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_PROTOCOL_SS = 0
	Const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_PROTOCOL_SSP = 1
	
	Union _USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED
		AsUlong32 As ULong
		'' TODO: __C89_NAMELESS struct { ULONG SublinkSpeedAttrID:4; ULONG LaneSpeedExponent:2; ULONG SublinkTypeMode:1; ULONG SublinkTypeDir:1; ULONG Reserved:6; ULONG LinkProtocol:2; ULONG LaneSpeedMantissa:16; };
	End Union
	
	Type USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED As _USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED
	Type PUSB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED As _USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED Ptr
	
	Union _USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR_bmAttributes
		AsUlong As ULong
		'' TODO: __C89_NAMELESS struct { ULONG SublinkSpeedAttrCount:5; ULONG SublinkSpeedIDCount:4; ULONG Reserved:23; };
	End Union
	
	union _USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR_wFunctionalitySupport
		AsUshort As UShort
		'' TODO: __C89_NAMELESS struct { USHORT SublinkSpeedAttrID:4; USHORT Reserved:4; USHORT MinRxLaneCount:4; USHORT MinTxLaneCount:4; };
	End Union
	
	Type _USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bDevCapabilityType As UCHAR
		bReserved As UCHAR
		bmAttributes As _USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR_bmAttributes
		wFunctionalitySupport As _USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR_wFunctionalitySupport
		wReserved As UShort
		bmSublinkSpeedAttr(0 To 0) As USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED
	End Type
	
	Type USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR As _USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR
	Type PUSB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR As _USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR Ptr
	
	Type _USB_DEVICE_CAPABILITY_CONTAINER_ID_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bDevCapabilityType As UCHAR
		bReserved As UCHAR
		ContainerID(0 To 15) As UCHAR
	End Type
	
	Type USB_DEVICE_CAPABILITY_CONTAINER_ID_DESCRIPTOR As _USB_DEVICE_CAPABILITY_CONTAINER_ID_DESCRIPTOR
	Type PUSB_DEVICE_CAPABILITY_CONTAINER_ID_DESCRIPTOR As _USB_DEVICE_CAPABILITY_CONTAINER_ID_DESCRIPTOR Ptr
	
	Type _USB_DEVICE_CAPABILITY_PLATFORM_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bDevCapabilityType As UCHAR
		bReserved As UCHAR
		PlatformCapabilityUuid As GUID
		CapabililityData(0 To 0) As UCHAR
	End Type
	
	Type USB_DEVICE_CAPABILITY_PLATFORM_DESCRIPTOR As _USB_DEVICE_CAPABILITY_PLATFORM_DESCRIPTOR
	Type PUSB_DEVICE_CAPABILITY_PLATFORM_DESCRIPTOR As _USB_DEVICE_CAPABILITY_PLATFORM_DESCRIPTOR Ptr
	
	Union _USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR_VconnPower
		AsUshort As UShort
		'' TODO: __C89_NAMELESS struct { USHORT VConnPowerNeededForFullFunctionality:3; USHORT Reserved:12; USHORT NoVconnPowerRequired:1; };
	End Union
	
	Type _USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bDevCapabilityType As UCHAR
		iAddtionalInfoURL As UCHAR
		bNumberOfAlternateModes As UCHAR
		bPreferredAlternateMode As UCHAR
		VconnPower As _USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR_VconnPower
		bmConfigured(0 To 31) As UCHAR
		bReserved As ULong
		'' TODO: __C89_NAMELESS struct { USHORT wSVID; UCHAR bAlternateMode; UCHAR iAlternateModeSetting; } AlternateMode[1];
	End Type
	
	Type USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR As _USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR
	Type PUSB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR As _USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR Ptr
	'' TODO: DEFINE_GUID(GUID_USB_MSOS20_PLATFORM_CAPABILITY_ID, 0xD8DD60DF, 0x4589, 0x4CC7, 0x9C, 0xD2, 0x65, 0x9D, 0x9E, 0x64, 0x8A, 0x9F);
	
	Type _USB_DEVICE_CAPABILITY_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bDevCapabilityType As UCHAR
	End Type
	
	Type USB_DEVICE_CAPABILITY_DESCRIPTOR As _USB_DEVICE_CAPABILITY_DESCRIPTOR
	Type PUSB_DEVICE_CAPABILITY_DESCRIPTOR As _USB_DEVICE_CAPABILITY_DESCRIPTOR Ptr
	
	Type _USB_CONFIGURATION_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		wTotalLength As UShort
		bNumInterfaces As UCHAR
		bConfigurationValue As UCHAR
		iConfiguration As UCHAR
		bmAttributes As UCHAR
		MaxPower As UCHAR
	End Type
	
	Type USB_CONFIGURATION_DESCRIPTOR As _USB_CONFIGURATION_DESCRIPTOR
	Type PUSB_CONFIGURATION_DESCRIPTOR As _USB_CONFIGURATION_DESCRIPTOR Ptr
	Const USB_CONFIG_POWERED_MASK = &hc0
	Const USB_CONFIG_BUS_POWERED = &h80
	Const USB_CONFIG_SELF_POWERED = &h40
	Const USB_CONFIG_REMOTE_WAKEUP = &h20
	Const USB_CONFIG_RESERVED = &h1f
	
	Type _USB_INTERFACE_ASSOCIATION_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bFirstInterface As UCHAR
		bInterfaceCount As UCHAR
		bFunctionClass As UCHAR
		bFunctionSubClass As UCHAR
		bFunctionProtocol As UCHAR
		iFunction As UCHAR
	End Type
	
	Type USB_INTERFACE_ASSOCIATION_DESCRIPTOR As _USB_INTERFACE_ASSOCIATION_DESCRIPTOR
	Type PUSB_INTERFACE_ASSOCIATION_DESCRIPTOR As _USB_INTERFACE_ASSOCIATION_DESCRIPTOR Ptr
	
	Type _USB_INTERFACE_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bInterfaceNumber As UCHAR
		bAlternateSetting As UCHAR
		bNumEndpoints As UCHAR
		bInterfaceClass As UCHAR
		bInterfaceSubClass As UCHAR
		bInterfaceProtocol As UCHAR
		iInterface As UCHAR
	End Type
	
	Type USB_INTERFACE_DESCRIPTOR As _USB_INTERFACE_DESCRIPTOR
	Type PUSB_INTERFACE_DESCRIPTOR As _USB_INTERFACE_DESCRIPTOR Ptr
	
	Type _USB_ENDPOINT_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bEndpointAddress As UCHAR
		bmAttributes As UCHAR
		wMaxPacketSize As UShort
		bInterval As UCHAR
	End Type
	
	Type USB_ENDPOINT_DESCRIPTOR As _USB_ENDPOINT_DESCRIPTOR
	Type PUSB_ENDPOINT_DESCRIPTOR As _USB_ENDPOINT_DESCRIPTOR Ptr
	const USB_ENDPOINT_DIRECTION_MASK = &h80
	#define USB_ENDPOINT_DIRECTION_OUT(addr) (((addr) and USB_ENDPOINT_DIRECTION_MASK) = 0)
	#define USB_ENDPOINT_DIRECTION_IN(addr) ((addr) and USB_ENDPOINT_DIRECTION_MASK)
	const USB_ENDPOINT_ADDRESS_MASK = &h0f
	Const USB_ENDPOINT_TYPE_MASK = &h03
	Const USB_ENDPOINT_TYPE_CONTROL = &h00
	Const USB_ENDPOINT_TYPE_ISOCHRONOUS = &h01
	Const USB_ENDPOINT_TYPE_BULK = &h02
	Const USB_ENDPOINT_TYPE_INTERRUPT = &h03
	Const USB_ENDPOINT_TYPE_BULK_RESERVED_MASK = &hfc
	Const USB_ENDPOINT_TYPE_CONTROL_RESERVED_MASK = &hfc
	Const USB_20_ENDPOINT_TYPE_INTERRUPT_RESERVED_MASK = &hfc
	Const USB_30_ENDPOINT_TYPE_INTERRUPT_RESERVED_MASK = &hcc
	Const USB_ENDPOINT_TYPE_ISOCHRONOUS_RESERVED_MASK = &hc0
	Const USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_MASK = &h30
	Const USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_PERIODIC = &h00
	Const USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_NOTIFICATION = &h10
	Const USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_RESERVED10 = &h20
	Const USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_RESERVED11 = &h30
	#define USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE(bmAttr) (bmAttr And USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_MASK)
	Const USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_MASK = &h0c
	Const USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_NO_SYNCHRONIZATION = &h00
	Const USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_ASYNCHRONOUS = &h04
	Const USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_ADAPTIVE = &h08
	Const USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_SYNCHRONOUS = &h0c
	#define USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION(bmAttr) (bmAttr And USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_MASK)
	Const USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_MASK = &h30
	Const USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_DATA_ENDOINT = &h00
	Const USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_FEEDBACK_ENDPOINT = &h10
	Const USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_IMPLICIT_FEEDBACK_DATA_ENDPOINT = &h20
	Const USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_RESERVED = &h30
	#define USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE(bmAttr) (bmAttr And USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_MASK)
	
	Union _USB_HIGH_SPEED_MAXPACKET
		'' TODO: __C89_NAMELESS struct _MP { USHORT MaxPacket : 11; USHORT HSmux : 2; USHORT Reserved : 3; };
		us As UShort
	End Union
	
	Type USB_HIGH_SPEED_MAXPACKET As _USB_HIGH_SPEED_MAXPACKET
	Type PUSB_HIGH_SPEED_MAXPACKET As _USB_HIGH_SPEED_MAXPACKET Ptr
	Const USB_ENDPOINT_SUPERSPEED_BULK_MAX_PACKET_SIZE = 1024
	Const USB_ENDPOINT_SUPERSPEED_CONTROL_MAX_PACKET_SIZE = 512
	Const USB_ENDPOINT_SUPERSPEED_ISO_MAX_PACKET_SIZE = 1024
	Const USB_ENDPOINT_SUPERSPEED_INTERRUPT_MAX_PACKET_SIZE = 1024
	Const MAXIMUM_USB_STRING_LENGTH = 255
	
	Type _USB_STRING_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bString As WString * MAXIMUM_USB_STRING_LENGTH
		'bString(0 To 0) As WCHAR
	End Type
	
	Type USB_STRING_DESCRIPTOR As _USB_STRING_DESCRIPTOR
	Type PUSB_STRING_DESCRIPTOR As _USB_STRING_DESCRIPTOR Ptr
	
	Type _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes_Bulk
		MaxStreams : 5 As UCHAR
		Reserved1 : 3 As UCHAR
	End Type
	
	Type _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes_Isochronous
		Mult : 2 As UCHAR
		Reserved2 : 5 As UCHAR
		SspCompanion : 1 As UCHAR
	End Type
	
	Union _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes
		AsUchar As UCHAR
		Bulk As _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes_Bulk
		Isochronous As _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes_Isochronous
	End Union
	
	Type _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bMaxBurst As UCHAR
		bmAttributes As _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes
		wBytesPerInterval As UShort
	End Type
	
	Type USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR As _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR
	Type PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR As _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR Ptr
	Const USB_SUPERSPEED_ISOCHRONOUS_MAX_MULTIPLIER = 2
	
	Type _USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		wReserved As UShort
		dwBytesPerInterval As ULong
	End Type
	
	Type USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR As _USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR
	Type PUSB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR As _USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR Ptr
	Const USB_SUPERSPEEDPLUS_ISOCHRONOUS_MIN_BYTESPERINTERVAL = &hc001
	Const USB_SUPERSPEEDPLUS_ISOCHRONOUS_MAX_BYTESPERINTERVAL = &hffffff
	
	Type _USB_HUB_DESCRIPTOR
		bDescriptorLength As UCHAR
		bDescriptorType As UCHAR
		bNumberOfPorts As UCHAR
		wHubCharacteristics As UShort
		bPowerOnToPowerGood As UCHAR
		bHubControlCurrent As UCHAR
		bRemoveAndPowerMask(0 To 63) As UCHAR
	End Type
	
	Type USB_HUB_DESCRIPTOR As _USB_HUB_DESCRIPTOR
	Type PUSB_HUB_DESCRIPTOR As _USB_HUB_DESCRIPTOR Ptr
	Const USB_20_HUB_DESCRIPTOR_TYPE = &h29
	
	Type _USB_30_HUB_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bNumberOfPorts As UCHAR
		wHubCharacteristics As UShort
		bPowerOnToPowerGood As UCHAR
		bHubControlCurrent As UCHAR
		bHubHdrDecLat As UCHAR
		wHubDelay As UShort
		DeviceRemovable As UShort
	End Type
	
	Type USB_30_HUB_DESCRIPTOR As _USB_30_HUB_DESCRIPTOR
	Type PUSB_30_HUB_DESCRIPTOR As _USB_30_HUB_DESCRIPTOR Ptr
	Const USB_30_HUB_DESCRIPTOR_TYPE = &h2a
	Const USB_REQUEST_GET_STATE = &h02
	Const USB_REQUEST_CLEAR_TT_BUFFER = &h08
	Const USB_REQUEST_RESET_TT = &h09
	Const USB_REQUEST_GET_TT_STATE = &h0a
	Const USB_REQUEST_STOP_TT = &h0b
	Const USB_REQUEST_SET_HUB_DEPTH = &h0c
	Const USB_REQUEST_GET_PORT_ERR_COUNT = &h0d
	
	Union _USB_HUB_STATUS
		AsUshort16 As UShort
		'' TODO: __C89_NAMELESS struct { USHORT LocalPowerLost:1; USHORT OverCurrent:1; USHORT Reserved:14; };
	End Union
	
	Type USB_HUB_STATUS As _USB_HUB_STATUS
	Type PUSB_HUB_STATUS As _USB_HUB_STATUS Ptr
	
	Union _USB_HUB_CHANGE
		AsUshort16 As UShort
		'' TODO: __C89_NAMELESS struct { USHORT LocalPowerChange:1; USHORT OverCurrentChange:1; USHORT Reserved:14; };
	End Union
	
	Type USB_HUB_CHANGE As _USB_HUB_CHANGE
	Type PUSB_HUB_CHANGE As _USB_HUB_CHANGE Ptr
	
	Union _USB_HUB_STATUS_AND_CHANGE
		AsUlong32 As ULong
		'' TODO: __C89_NAMELESS struct { USB_HUB_STATUS HubStatus; USB_HUB_CHANGE HubChange; };
	End Union
	
	Type USB_HUB_STATUS_AND_CHANGE As _USB_HUB_STATUS_AND_CHANGE
	Type PUSB_HUB_STATUS_AND_CHANGE As _USB_HUB_STATUS_AND_CHANGE Ptr
	
	Union _USB_20_PORT_STATUS
		AsUshort16 As UShort
		'' TODO: __C89_NAMELESS struct { USHORT CurrentConnectStatus:1; USHORT PortEnabledDisabled:1; USHORT Suspend:1; USHORT OverCurrent:1; USHORT Reset:1; USHORT Reserved0:3; USHORT PortPower:1; USHORT LowSpeedDeviceAttached:1; USHORT HighSpeedDeviceAttached:1; USHORT PortTestMode:1; USHORT PortIndicatorControl:1; USHORT Reserved1:3; };
	End Union
	
	Type USB_20_PORT_STATUS As _USB_20_PORT_STATUS
	Type PUSB_20_PORT_STATUS As _USB_20_PORT_STATUS Ptr
	Const USB_PORT_STATUS_CONNECT = &h0001
	Const USB_PORT_STATUS_ENABLE = &h0002
	Const USB_PORT_STATUS_SUSPEND = &h0004
	Const USB_PORT_STATUS_OVER_CURRENT = &h0008
	Const USB_PORT_STATUS_RESET = &h0010
	Const USB_PORT_STATUS_POWER = &h0100
	Const USB_PORT_STATUS_LOW_SPEED = &h0200
	Const USB_PORT_STATUS_HIGH_SPEED = &h0400
	
	Union _USB_20_PORT_CHANGE
		AsUshort16 As UShort
		'' TODO: __C89_NAMELESS struct { USHORT ConnectStatusChange:1; USHORT PortEnableDisableChange:1; USHORT SuspendChange:1; USHORT OverCurrentIndicatorChange:1; USHORT ResetChange:1; USHORT Reserved2:11; };
	End Union
	
	Type USB_20_PORT_CHANGE As _USB_20_PORT_CHANGE
	Type PUSB_20_PORT_CHANGE As _USB_20_PORT_CHANGE Ptr
	
	Union _USB_30_PORT_STATUS
		AsUshort16 As UShort
		'' TODO: __C89_NAMELESS struct { USHORT CurrentConnectStatus:1; USHORT PortEnabledDisabled:1; USHORT Reserved0:1; USHORT OverCurrent:1; USHORT Reset:1; USHORT PortLinkState:4; USHORT PortPower:1; USHORT NegotiatedDeviceSpeed:3; USHORT Reserved1:3; };
	End Union
	
	Type USB_30_PORT_STATUS As _USB_30_PORT_STATUS
	Type PUSB_30_PORT_STATUS As _USB_30_PORT_STATUS Ptr
	Const PORT_LINK_STATE_U0 = 0
	Const PORT_LINK_STATE_U1 = 1
	Const PORT_LINK_STATE_U2 = 2
	Const PORT_LINK_STATE_U3 = 3
	Const PORT_LINK_STATE_DISABLED = 4
	Const PORT_LINK_STATE_RX_DETECT = 5
	Const PORT_LINK_STATE_INACTIVE = 6
	Const PORT_LINK_STATE_POLLING = 7
	Const PORT_LINK_STATE_RECOVERY = 8
	Const PORT_LINK_STATE_HOT_RESET = 9
	Const PORT_LINK_STATE_COMPLIANCE_MODE = 10
	Const PORT_LINK_STATE_LOOPBACK = 11
	Const PORT_LINK_STATE_TEST_MODE = 11
	
	Union _USB_30_PORT_CHANGE
		AsUshort16 As UShort
		'' TODO: __C89_NAMELESS struct { USHORT ConnectStatusChange:1; USHORT Reserved2:2; USHORT OverCurrentIndicatorChange:1; USHORT ResetChange:1; USHORT BHResetChange:1; USHORT PortLinkStateChange:1; USHORT PortConfigErrorChange:1; USHORT Reserved3:8; };
	End Union
	
	Type USB_30_PORT_CHANGE As _USB_30_PORT_CHANGE
	Type PUSB_30_PORT_CHANGE As _USB_30_PORT_CHANGE Ptr
	
	Union _USB_PORT_STATUS
		AsUshort16 As UShort
		Usb20PortStatus As USB_20_PORT_STATUS
		Usb30PortStatus As USB_30_PORT_STATUS
	End Union
	
	Type USB_PORT_STATUS As _USB_PORT_STATUS
	Type PUSB_PORT_STATUS As _USB_PORT_STATUS Ptr
	
	Union _USB_PORT_CHANGE
		AsUshort16 As UShort
		Usb20PortChange As USB_20_PORT_CHANGE
		Usb30PortChange As USB_30_PORT_CHANGE
	End Union
	
	Type USB_PORT_CHANGE As _USB_PORT_CHANGE
	Type PUSB_PORT_CHANGE As _USB_PORT_CHANGE Ptr
	
	Union _USB_PORT_EXT_STATUS
		AsUlong32 As ULong
		'' TODO: __C89_NAMELESS struct { ULONG RxSublinkSpeedID:4; ULONG TxSublinkSpeedID:4; ULONG RxLaneCount:4; ULONG TxLaneCount:4; ULONG Reserved:16; };
	End Union
	
	Type USB_PORT_EXT_STATUS As _USB_PORT_EXT_STATUS
	Type PUSB_PORT_EXT_STATUS As _USB_PORT_EXT_STATUS Ptr
	
	Union _USB_PORT_STATUS_AND_CHANGE
		AsUlong32 As ULong
		'' TODO: __C89_NAMELESS struct { USB_PORT_STATUS PortStatus; USB_PORT_CHANGE PortChange; };
	End Union
	
	Type USB_PORT_STATUS_AND_CHANGE As _USB_PORT_STATUS_AND_CHANGE
	Type PUSB_PORT_STATUS_AND_CHANGE As _USB_PORT_STATUS_AND_CHANGE Ptr
	
	Union _USB_PORT_EXT_STATUS_AND_CHANGE
		AsUlong64 As ULONG64
		'' TODO: __C89_NAMELESS struct { USB_PORT_STATUS_AND_CHANGE PortStatusChange; USB_PORT_EXT_STATUS PortExtStatus; };
	End Union
	
	Type USB_PORT_EXT_STATUS_AND_CHANGE As _USB_PORT_EXT_STATUS_AND_CHANGE
	Type PUSB_PORT_EXT_STATUS_AND_CHANGE As _USB_PORT_EXT_STATUS_AND_CHANGE Ptr
	
	Union _USB_HUB_30_PORT_REMOTE_WAKE_MASK
		AsUchar8 As UCHAR
		'' TODO: __C89_NAMELESS struct { UCHAR ConnectRemoteWakeEnable:1; UCHAR DisconnectRemoteWakeEnable:1; UCHAR OverCurrentRemoteWakeEnable:1; UCHAR Reserved0:5; };
	End Union
	
	Type USB_HUB_30_PORT_REMOTE_WAKE_MASK As _USB_HUB_30_PORT_REMOTE_WAKE_MASK
	Type PUSB_HUB_30_PORT_REMOTE_WAKE_MASK As _USB_HUB_30_PORT_REMOTE_WAKE_MASK Ptr
	
	Union _USB_FUNCTION_SUSPEND_OPTIONS
		AsUchar As UCHAR
		'' TODO: __C89_NAMELESS struct { UCHAR PowerState:1; UCHAR RemoteWakeEnabled:1; UCHAR Reserved:6; };
	End Union
	
	Type USB_FUNCTION_SUSPEND_OPTIONS As _USB_FUNCTION_SUSPEND_OPTIONS
	Type PUSB_FUNCTION_SUSPEND_OPTIONS As _USB_FUNCTION_SUSPEND_OPTIONS Ptr
	Const USB_FEATURE_INTERFACE_POWER_D0 = &h0002
	Const USB_FEATURE_INTERFACE_POWER_D1 = &h0003
	Const USB_FEATURE_INTERFACE_POWER_D2 = &h0004
	Const USB_FEATURE_INTERFACE_POWER_D3 = &h0005
	Const USB_SUPPORT_D0_COMMAND = &h01
	Const USB_SUPPORT_D1_COMMAND = &h02
	Const USB_SUPPORT_D2_COMMAND = &h04
	Const USB_SUPPORT_D3_COMMAND = &h08
	Const USB_SUPPORT_D1_WAKEUP = &h10
	Const USB_SUPPORT_D2_WAKEUP = &h20
	
	Type _USB_CONFIGURATION_POWER_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		SelfPowerConsumedD0(0 To 2) As UCHAR
		bPowerSummaryId As UCHAR
		bBusPowerSavingD1 As UCHAR
		bSelfPowerSavingD1 As UCHAR
		bBusPowerSavingD2 As UCHAR
		bSelfPowerSavingD2 As UCHAR
		bBusPowerSavingD3 As UCHAR
		bSelfPowerSavingD3 As UCHAR
		TransitionTimeFromD1 As UShort
		TransitionTimeFromD2 As UShort
		TransitionTimeFromD3 As UShort
	End Type
	
	Type USB_CONFIGURATION_POWER_DESCRIPTOR As _USB_CONFIGURATION_POWER_DESCRIPTOR
	Type PUSB_CONFIGURATION_POWER_DESCRIPTOR As _USB_CONFIGURATION_POWER_DESCRIPTOR Ptr
	
	Type _USB_INTERFACE_POWER_DESCRIPTOR
		bLength As UCHAR
		bDescriptorType As UCHAR
		bmCapabilitiesFlags As UCHAR
		bBusPowerSavingD1 As UCHAR
		bSelfPowerSavingD1 As UCHAR
		bBusPowerSavingD2 As UCHAR
		bSelfPowerSavingD2 As UCHAR
		bBusPowerSavingD3 As UCHAR
		bSelfPowerSavingD3 As UCHAR
		TransitionTimeFromD1 As UShort
		TransitionTimeFromD2 As UShort
		TransitionTimeFromD3 As UShort
	End Type
	
	Type USB_INTERFACE_POWER_DESCRIPTOR As _USB_INTERFACE_POWER_DESCRIPTOR
	Type PUSB_INTERFACE_POWER_DESCRIPTOR As _USB_INTERFACE_POWER_DESCRIPTOR Ptr
	#define __USBIODEF_H__
	Const USB_SUBMIT_URB = 0
	Const USB_RESET_PORT = 1
	Const USB_GET_ROOTHUB_PDO = 3
	Const USB_GET_PORT_STATUS = 4
	Const USB_ENABLE_PORT = 5
	Const USB_GET_HUB_COUNT = 6
	Const USB_CYCLE_PORT = 7
	Const USB_GET_HUB_NAME = 8
	Const USB_IDLE_NOTIFICATION = 9
	Const USB_RECORD_FAILURE = 10
	Const USB_GET_BUS_INFO = 264
	Const USB_GET_CONTROLLER_NAME = 265
	Const USB_GET_BUSGUID_INFO = 266
	Const USB_GET_PARENT_HUB_INFO = 267
	Const USB_GET_DEVICE_HANDLE = 268
	Const USB_GET_DEVICE_HANDLE_EX = 269
	Const USB_GET_TT_DEVICE_HANDLE = 270
	Const USB_GET_TOPOLOGY_ADDRESS = 271
	Const USB_IDLE_NOTIFICATION_EX = 272
	Const USB_REQ_GLOBAL_SUSPEND = 273
	Const USB_REQ_GLOBAL_RESUME = 274
	Const USB_GET_HUB_CONFIG_INFO = 275
	Const USB_REGISTER_COMPOSITE_DEVICE = 0
	Const USB_UNREGISTER_COMPOSITE_DEVICE = 1
	Const USB_REQUEST_REMOTE_WAKE_NOTIFICATION = 2
	Const HCD_GET_STATS_1 = 255
	Const HCD_DIAGNOSTIC_MODE_ON = 256
	Const HCD_DIAGNOSTIC_MODE_OFF = 257
	Const HCD_GET_ROOT_HUB_NAME = 258
	Const HCD_GET_DRIVERKEY_NAME = 265
	Const HCD_GET_STATS_2 = 266
	Const HCD_DISABLE_PORT = 268
	Const HCD_ENABLE_PORT = 269
	Const HCD_USER_REQUEST = 270
	Const HCD_TRACE_READ_REQUEST = 275
	Const USB_GET_NODE_INFORMATION = 258
	Const USB_GET_NODE_CONNECTION_INFORMATION = 259
	Const USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION = 260
	Const USB_GET_NODE_CONNECTION_NAME = 261
	Const USB_DIAG_IGNORE_HUBS_ON = 262
	Const USB_DIAG_IGNORE_HUBS_OFF = 263
	Const USB_GET_NODE_CONNECTION_DRIVERKEY_NAME = 264
	Const USB_GET_HUB_CAPABILITIES = 271
	Const USB_GET_NODE_CONNECTION_ATTRIBUTES = 272
	Const USB_HUB_CYCLE_PORT = 273
	Const USB_GET_NODE_CONNECTION_INFORMATION_EX = 274
	Const USB_RESET_HUB = 275
	Const USB_GET_HUB_CAPABILITIES_EX = 276
	Const USB_GET_HUB_INFORMATION_EX = 277
	Const USB_GET_PORT_CONNECTOR_PROPERTIES = 278
	Const USB_GET_NODE_CONNECTION_INFORMATION_EX_V2 = 279
	#define GUID_CLASS_USBHUB GUID_DEVINTERFACE_USB_HUB
	#define GUID_CLASS_USB_DEVICE GUID_DEVINTERFACE_USB_DEVICE
	#define GUID_CLASS_USB_HOST_CONTROLLER GUID_DEVINTERFACE_USB_HOST_CONTROLLER
	#define FILE_DEVICE_USB FILE_DEVICE_UNKNOWN
	#define USB_CTL(id) CTL_CODE(FILE_DEVICE_USB, (id), METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define USB_KERNEL_CTL(id) CTL_CODE(FILE_DEVICE_USB, (id), METHOD_NEITHER, FILE_ANY_ACCESS)
	#define USB_KERNEL_CTL_BUFFERED(id) CTL_CODE(FILE_DEVICE_USB, (id), METHOD_BUFFERED, FILE_ANY_ACCESS)
	
	'' TODO: DEFINE_GUID (GUID_DEVINTERFACE_USB_HUB, 0xf18a0e88, 0xc30c, 0x11d0, 0x88, 0x15, 0x00, 0xa0, 0xc9, 0x06, 0xbe, 0xd8);
	'' TODO: DEFINE_GUID (GUID_DEVINTERFACE_USB_DEVICE, 0xa5dcbf10, 0x6530, 0x11d2, 0x90, 0x1f, 0x00, 0xc0, 0x4f, 0xb9, 0x51, 0xed);
	'' TODO: DEFINE_GUID (GUID_DEVINTERFACE_USB_HOST_CONTROLLER, 0x3abf6f2d, 0x71c4, 0x462a, 0x8a, 0x92, 0x1e, 0x68, 0x61, 0xe6, 0xaf, 0x27);
	'' TODO: DEFINE_GUID (GUID_USB_WMI_STD_DATA, 0x4e623b20, 0xcb14, 0x11d1, 0xb3, 0x31, 0x00, 0xa0, 0xc9, 0x59, 0xbb, 0xd2);
	'' TODO: DEFINE_GUID (GUID_USB_WMI_STD_NOTIFICATION, 0x4e623b20, 0xcb14, 0x11d1, 0xb3, 0x31, 0x00, 0xa0, 0xc9, 0x59, 0xbb, 0xd2);
	Type USB_IDLE_CALLBACK As Function(ByVal CONTEXT As PVOID) As Any Ptr
	
	Type _USB_IDLE_CALLBACK_INFO
		IdleCallback As USB_IDLE_CALLBACK
		IdleContext As PVOID
	End Type
	
	Type USB_IDLE_CALLBACK_INFO As _USB_IDLE_CALLBACK_INFO
	Type PUSB_IDLE_CALLBACK_INFO As _USB_IDLE_CALLBACK_INFO Ptr
	#define IOCTL_INTERNAL_USB_SUBMIT_URB CTL_CODE(FILE_DEVICE_USB, USB_SUBMIT_URB, METHOD_NEITHER, FILE_ANY_ACCESS)
	#define IOCTL_INTERNAL_USB_RESET_PORT CTL_CODE(FILE_DEVICE_USB, USB_RESET_PORT, METHOD_NEITHER, FILE_ANY_ACCESS)
	#define IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO CTL_CODE(FILE_DEVICE_USB, USB_GET_ROOTHUB_PDO, METHOD_NEITHER, FILE_ANY_ACCESS)
	Const USBD_PORT_ENABLED = &h00000001
	Const USBD_PORT_CONNECTED = &h00000002
	#define IOCTL_INTERNAL_USB_GET_PORT_STATUS CTL_CODE(FILE_DEVICE_USB, USB_GET_PORT_STATUS, METHOD_NEITHER, FILE_ANY_ACCESS)
	#define IOCTL_INTERNAL_USB_ENABLE_PORT CTL_CODE(FILE_DEVICE_USB, USB_ENABLE_PORT, METHOD_NEITHER, FILE_ANY_ACCESS)
	#define IOCTL_INTERNAL_USB_GET_HUB_COUNT CTL_CODE(FILE_DEVICE_USB, USB_GET_HUB_COUNT, METHOD_NEITHER, FILE_ANY_ACCESS)
	#define IOCTL_INTERNAL_USB_CYCLE_PORT CTL_CODE(FILE_DEVICE_USB, USB_CYCLE_PORT, METHOD_NEITHER, FILE_ANY_ACCESS)
	#define IOCTL_INTERNAL_USB_GET_HUB_NAME CTL_CODE(FILE_DEVICE_USB, USB_GET_HUB_NAME, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_INTERNAL_USB_GET_BUS_INFO CTL_CODE(FILE_DEVICE_USB, USB_GET_BUS_INFO, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_INTERNAL_USB_GET_CONTROLLER_NAME CTL_CODE(FILE_DEVICE_USB, USB_GET_CONTROLLER_NAME, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_INTERNAL_USB_GET_BUSGUID_INFO CTL_CODE(FILE_DEVICE_USB, USB_GET_BUSGUID_INFO, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO CTL_CODE(FILE_DEVICE_USB, USB_GET_PARENT_HUB_INFO, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION CTL_CODE(FILE_DEVICE_USB, USB_IDLE_NOTIFICATION, METHOD_NEITHER, FILE_ANY_ACCESS)
	#define IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE CTL_CODE(FILE_DEVICE_USB, USB_GET_DEVICE_HANDLE, METHOD_NEITHER, FILE_ANY_ACCESS)
	#define IOCTL_USB_HCD_GET_STATS_1 CTL_CODE(FILE_DEVICE_USB, HCD_GET_STATS_1, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_HCD_GET_STATS_2 CTL_CODE(FILE_DEVICE_USB, HCD_GET_STATS_2, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_HCD_DISABLE_PORT CTL_CODE(FILE_DEVICE_USB, HCD_DISABLE_PORT, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_HCD_ENABLE_PORT CTL_CODE(FILE_DEVICE_USB, HCD_ENABLE_PORT, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_DIAGNOSTIC_MODE_ON CTL_CODE(FILE_DEVICE_USB, HCD_DIAGNOSTIC_MODE_ON, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_DIAGNOSTIC_MODE_OFF CTL_CODE(FILE_DEVICE_USB, HCD_DIAGNOSTIC_MODE_OFF, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_GET_ROOT_HUB_NAME CTL_CODE(FILE_DEVICE_USB, HCD_GET_ROOT_HUB_NAME, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_GET_HCD_DRIVERKEY_NAME CTL_CODE(FILE_DEVICE_USB, HCD_GET_DRIVERKEY_NAME, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_GET_NODE_INFORMATION CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_INFORMATION, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_CONNECTION_INFORMATION, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION CTL_CODE(FILE_DEVICE_USB, USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_GET_NODE_CONNECTION_NAME CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_CONNECTION_NAME, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_DIAG_IGNORE_HUBS_ON CTL_CODE(FILE_DEVICE_USB, USB_DIAG_IGNORE_HUBS_ON, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_DIAG_IGNORE_HUBS_OFF CTL_CODE(FILE_DEVICE_USB, USB_DIAG_IGNORE_HUBS_OFF, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_CONNECTION_DRIVERKEY_NAME, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_GET_HUB_CAPABILITIES CTL_CODE(FILE_DEVICE_USB, USB_GET_HUB_CAPABILITIES, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_HUB_CYCLE_PORT CTL_CODE(FILE_DEVICE_USB, USB_HUB_CYCLE_PORT, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_GET_NODE_CONNECTION_ATTRIBUTES CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_CONNECTION_ATTRIBUTES, METHOD_BUFFERED, FILE_ANY_ACCESS)
	#define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_CONNECTION_INFORMATION_EX, METHOD_BUFFERED, FILE_ANY_ACCESS)
	
	Type _USB_HUB_NODE As Long
	Enum
		UsbHub
		UsbMIParent
	End Enum
	
	Type USB_HUB_NODE As _USB_HUB_NODE
	
	Type _USB_HUB_INFORMATION
		HubDescriptor As USB_HUB_DESCRIPTOR
		HubIsBusPowered As Boolean
	End Type
	
	Type USB_HUB_INFORMATION As _USB_HUB_INFORMATION
	Type PUSB_HUB_INFORMATION As _USB_HUB_INFORMATION Ptr
	
	Type _USB_MI_PARENT_INFORMATION
		NumberOfInterfaces As ULong
	End Type
	
	Type USB_MI_PARENT_INFORMATION As _USB_MI_PARENT_INFORMATION
	Type PUSB_MI_PARENT_INFORMATION As _USB_MI_PARENT_INFORMATION Ptr
	
	Union _USB_NODE_INFORMATION_u
		HubInformation As USB_HUB_INFORMATION
		MiParentInformation As USB_MI_PARENT_INFORMATION
	End Union
	
	Type _USB_NODE_INFORMATION
		NodeType As USB_HUB_NODE
		u As _USB_NODE_INFORMATION_u
	End Type
	
	Type USB_NODE_INFORMATION As _USB_NODE_INFORMATION
	Type PUSB_NODE_INFORMATION As _USB_NODE_INFORMATION Ptr
	
	Type _USB_PIPE_INFO
		EndpointDescriptor As USB_ENDPOINT_DESCRIPTOR
		ScheduleOffset As ULong
	End Type
	
	Type USB_PIPE_INFO As _USB_PIPE_INFO
	Type PUSB_PIPE_INFO As _USB_PIPE_INFO Ptr
	
	Type _USB_CONNECTION_STATUS As Long
	Enum
		NoDeviceConnected
		DeviceConnected
		DeviceFailedEnumeration
		DeviceGeneralFailure
		DeviceCausedOvercurrent
		DeviceNotEnoughPower
		DeviceNotEnoughBandwidth
		DeviceHubNestedTooDeeply
		DeviceInLegacyHub
	End Enum
	
	Type USB_CONNECTION_STATUS As _USB_CONNECTION_STATUS
	Type PUSB_CONNECTION_STATUS As _USB_CONNECTION_STATUS Ptr
	
	Type _USB_NODE_CONNECTION_INFORMATION
		ConnectionIndex As ULong
		DeviceDescriptor As USB_DEVICE_DESCRIPTOR
		CurrentConfigurationValue As UCHAR
		LowSpeed As Boolean
		DeviceIsHub As Boolean
		DeviceAddress As UShort
		NumberOfOpenPipes As ULong
		ConnectionStatus As USB_CONNECTION_STATUS
		PipeList(1 To 32) As USB_PIPE_INFO
	End Type
	
	Type USB_NODE_CONNECTION_INFORMATION As _USB_NODE_CONNECTION_INFORMATION
	Type PUSB_NODE_CONNECTION_INFORMATION As _USB_NODE_CONNECTION_INFORMATION Ptr
	
	Type _USB_NODE_CONNECTION_DRIVERKEY_NAME
		ConnectionIndex As ULong
		ActualLength As ULong
		DriverKeyName As WString * MAXIMUM_USB_STRING_LENGTH
		'DriverKeyName(0 To 0) As WCHAR
	End Type
	
	Type USB_NODE_CONNECTION_DRIVERKEY_NAME As _USB_NODE_CONNECTION_DRIVERKEY_NAME
	Type PUSB_NODE_CONNECTION_DRIVERKEY_NAME As _USB_NODE_CONNECTION_DRIVERKEY_NAME Ptr
	
	Type _USB_NODE_CONNECTION_NAME
		ConnectionIndex As ULong
		ActualLength As ULong
		NodeName As WString * MAXIMUM_USB_STRING_LENGTH
		'NodeName(0 To 0) As WCHAR
	End Type
	
	Type USB_NODE_CONNECTION_NAME As _USB_NODE_CONNECTION_NAME
	Type PUSB_NODE_CONNECTION_NAME As _USB_NODE_CONNECTION_NAME Ptr
	
	Type _USB_HUB_NAME
		ActualLength As ULong
		HubName As WString * MAXIMUM_USB_STRING_LENGTH
		'HubName(0 To 0) As WCHAR
	End Type
	
	Type USB_HUB_NAME As _USB_HUB_NAME
	Type PUSB_HUB_NAME As _USB_HUB_NAME Ptr
	
	Type _USB_ROOT_HUB_NAME
		ActualLength As ULong
		RootHubName As WString * MAXIMUM_USB_STRING_LENGTH
		'RootHubName(0 To 0) As WCHAR
	End Type
	
	Type USB_ROOT_HUB_NAME As _USB_ROOT_HUB_NAME
	Type PUSB_ROOT_HUB_NAME As _USB_ROOT_HUB_NAME Ptr
	
	Type _USB_HCD_DRIVERKEY_NAME
		ActualLength As ULong
		DriverKeyName As WString * MAXIMUM_USB_STRING_LENGTH
		'DriverKeyName(0 To 0) As WCHAR
	End Type
	
	Type USB_HCD_DRIVERKEY_NAME As _USB_HCD_DRIVERKEY_NAME
	Type PUSB_HCD_DRIVERKEY_NAME As _USB_HCD_DRIVERKEY_NAME Ptr
	
	Type _USB_DESCRIPTOR_REQUEST_SetupPacket
		bmRequest As UCHAR
		bRequest As UCHAR
		wValue As UShort
		wIndex As UShort
		wLength As UShort
	End Type
	
	Type _USB_DESCRIPTOR_REQUEST
		ConnectionIndex As ULong
		SetupPacket As _USB_DESCRIPTOR_REQUEST_SetupPacket
		Data As WString * MAXIMUM_USB_STRING_LENGTH
		'Data(Any) As UCHAR
	End Type
	
	Type USB_DESCRIPTOR_REQUEST As _USB_DESCRIPTOR_REQUEST
	Type PUSB_DESCRIPTOR_REQUEST As _USB_DESCRIPTOR_REQUEST Ptr
	
	Type _USB_HUB_CAPABILITIES
		HubIs2xCapable : 1 As ULong
	End Type
	
	Type USB_HUB_CAPABILITIES As _USB_HUB_CAPABILITIES
	Type PUSB_HUB_CAPABILITIES As _USB_HUB_CAPABILITIES Ptr
	
	Type _USB_NODE_CONNECTION_ATTRIBUTES
		ConnectionIndex As ULong
		ConnectionStatus As USB_CONNECTION_STATUS
		PortAttributes As ULong
	End Type
	
	Type USB_NODE_CONNECTION_ATTRIBUTES As _USB_NODE_CONNECTION_ATTRIBUTES
	Type PUSB_NODE_CONNECTION_ATTRIBUTES As _USB_NODE_CONNECTION_ATTRIBUTES Ptr
	
	Type _USB_NODE_CONNECTION_INFORMATION_EX
		ConnectionIndex As ULong
		DeviceDescriptor As USB_DEVICE_DESCRIPTOR
		CurrentConfigurationValue As UCHAR
		Speed As UCHAR
		DeviceIsHub As Boolean
		DeviceAddress As UShort
		NumberOfOpenPipes As ULong
		ConnectionStatus As USB_CONNECTION_STATUS
		PipeList(1 To 32) As USB_PIPE_INFO
	End Type
	
	Type USB_NODE_CONNECTION_INFORMATION_EX As _USB_NODE_CONNECTION_INFORMATION_EX
	Type PUSB_NODE_CONNECTION_INFORMATION_EX As _USB_NODE_CONNECTION_INFORMATION_EX Ptr
	
	Type _HCD_STAT_COUNTERS
		BytesTransferred As ULong
		IsoMissedCount As UShort
		DataOverrunErrorCount As UShort
		CrcErrorCount As UShort
		ScheduleOverrunCount As UShort
		TimeoutErrorCount As UShort
		InternalHcErrorCount As UShort
		BufferOverrunErrorCount As UShort
		SWErrorCount As UShort
		StallPidCount As UShort
		PortDisableCount As UShort
	End Type
	
	Type HCD_STAT_COUNTERS As _HCD_STAT_COUNTERS
	Type PHCD_STAT_COUNTERS As _HCD_STAT_COUNTERS Ptr
	
	Type _HCD_ISO_STAT_COUNTERS
		LateUrbs As UShort
		DoubleBufferedPackets As UShort
		TransfersCF_5ms As UShort
		TransfersCF_2ms As UShort
		TransfersCF_1ms As UShort
		MaxInterruptLatency As UShort
		BadStartFrame As UShort
		StaleUrbs As UShort
		IsoPacketNotAccesed As UShort
		IsoPacketHWError As UShort
		SmallestUrbPacketCount As UShort
		LargestUrbPacketCount As UShort
		IsoCRC_Error As UShort
		IsoOVERRUN_Error As UShort
		IsoINTERNAL_Error As UShort
		IsoUNKNOWN_Error As UShort
		IsoBytesTransferred As ULong
		LateMissedCount As UShort
		HWIsoMissedCount As UShort
		Reserved7(0 To 7) As ULong
	End Type
	
	Type HCD_ISO_STAT_COUNTERS As _HCD_ISO_STAT_COUNTERS
	Type PHCD_ISO_STAT_COUNTERS As _HCD_ISO_STAT_COUNTERS Ptr
	
	Type _HCD_STAT_INFORMATION_1
		Reserved1 As ULong
		Reserved2 As ULong
		ResetCounters As ULong
		TimeRead As LARGE_INTEGER
		Counters As HCD_STAT_COUNTERS
	End Type
	
	Type HCD_STAT_INFORMATION_1 As _HCD_STAT_INFORMATION_1
	Type PHCD_STAT_INFORMATION_1 As _HCD_STAT_INFORMATION_1 Ptr
	
	Type _HCD_STAT_INFORMATION_2
		Reserved1 As ULong
		Reserved2 As ULong
		ResetCounters As ULong
		TimeRead As LARGE_INTEGER
		LockedMemoryUsed As Long
		Counters As HCD_STAT_COUNTERS
		IsoCounters As HCD_ISO_STAT_COUNTERS
	End Type
	
	Type HCD_STAT_INFORMATION_2 As _HCD_STAT_INFORMATION_2
	Type PHCD_STAT_INFORMATION_2 As _HCD_STAT_INFORMATION_2 Ptr
	Const WMI_USB_DRIVER_INFORMATION = 0
	Const WMI_USB_DRIVER_NOTIFICATION = 1
	Const WMI_USB_POWER_DEVICE_ENABLE = 2
	Const WMI_USB_HUB_NODE_INFORMATION = 4
	Const WMI_USB_PERFORMANCE_INFORMATION = 1
	Const WMI_USB_DEVICE_NODE_INFORMATION = 2
	
	Type _USB_NOTIFICATION_TYPE As Long
	Enum
		EnumerationFailure = 0
		InsufficentBandwidth
		InsufficentPower
		OverCurrent
		ResetOvercurrent
		AcquireBusInfo
		AcquireHubName
		AcquireControllerName
		HubOvercurrent
		HubPowerChange
		HubNestedTooDeeply
		ModernDeviceInLegacyHub
	End Enum
	
	Type USB_NOTIFICATION_TYPE As _USB_NOTIFICATION_TYPE
	
	Type _USB_NOTIFICATION
		NotificationType As USB_NOTIFICATION_TYPE
	End Type
	
	Type USB_NOTIFICATION As _USB_NOTIFICATION
	Type PUSB_NOTIFICATION As _USB_NOTIFICATION Ptr
	
	Type _USB_CONNECTION_NOTIFICATION
		NotificationType As USB_NOTIFICATION_TYPE
		ConnectionNumber As ULong
		RequestedBandwidth As ULong
		EnumerationFailReason As ULong
		PowerRequested As ULong
		HubNameLength As ULong
	End Type
	
	Type USB_CONNECTION_NOTIFICATION As _USB_CONNECTION_NOTIFICATION
	Type PUSB_CONNECTION_NOTIFICATION As _USB_CONNECTION_NOTIFICATION Ptr
	
	Type _USB_BUS_NOTIFICATION
		NotificationType As USB_NOTIFICATION_TYPE
		TotalBandwidth As ULong
		ConsumedBandwidth As ULong
		ControllerNameLength As ULong
	End Type
	
	Type USB_BUS_NOTIFICATION As _USB_BUS_NOTIFICATION
	Type PUSB_BUS_NOTIFICATION As _USB_BUS_NOTIFICATION Ptr
	
	Type _USB_ACQUIRE_INFO
		NotificationType As USB_NOTIFICATION_TYPE
		TotalSize As ULong
		Buffer As WString * MAXIMUM_USB_STRING_LENGTH
		'Buffer(0 To 0) As WCHAR
	End Type
	
	Type USB_ACQUIRE_INFO As _USB_ACQUIRE_INFO
	Type PUSB_ACQUIRE_INFO As _USB_ACQUIRE_INFO Ptr
	
End Extern
